#%RAML 1.0
title: 物理机装机平台API
baseUri: /api/osinstall/{version}
version: v1
mediaType: application/json

types:
  Nic:
    description: 网卡信息
    type: object
    properties:
      Name:
        description: 名称
        type: string
        required: true
      Mac:
        description: Mac地址
        type: string
        required: true
      Ip:
        description: IP
        type: string
        required: true

  Cpu:
    description: CPU信息
    type: object
    properties:
      Model:
        description: 型号
        type: string
        required: true
      Core:
        description: 核数
        type: string
        required: true

  Memory:
    description: 内存信息
    type: object
    properties:
      Name:
        description: 名称,如1,2,3,4等
        type: string
        required: true
      Size:
        description: 大小
        type: string
        required: true

  Disk:
    description: 硬盘信息
    type: object
    properties:
      Name:
        description: 名称,如1,2,3,4等
        type: string
        required: true
      Size:
        description: 大小
        type: string
        required: true

  Motherboard:
    description: 主板信息
    type: object
    properties:
      Name:
        description: 名称
        type: string
        required: true
      Model:
        description: 型号
        type: string
        required: true


/device/getHardwareBySn:
  post:
    description: 获取硬件配置信息(执行脚本做了base64encode处理，需要decode后再去调用执行)
    queryParameters:
      Sn:
        description: SN号
        type: string
        required: true
    responses:
      200:
        body:
          application/json:
            example: |               
              {
                "Content": {
                  "Company": "Dell",
                  "Hardware": [ #需要执行的脚本信息
                    {
                      "Name": "RAID",
                      "Scripts": [
                        {
                          "Name": "RAID",
                          "Script": "L29wdC95dW5qaS9vc2luc3RhbGwvZGVsbC9yYWlkLnNoIC1jIC1sIDEw" #经base64encode，需要base64decode处理后再执行
                        }
                      ]
                    },
                    {
                      "Name": "OOB",
                      "Scripts": [
                        {
                          "Name": "网络类型",
                          "Script": "L29wdC95dW5qaS9vc2luc3RhbGwvZGVsbC9vb2Iuc2ggLW4gZGhjcA=="
                        },
                        {
                          "Name": "用户名",
                          "Script": "L29wdC95dW5qaS9vc2luc3RhbGwvZGVsbC9vb2Iuc2ggLXUgcm9vdA=="
                        },
                        {
                          "Name": "密码",
                          "Script": "L29wdC95dW5qaS9vc2luc3RhbGwvZGVsbC9vb2Iuc2ggLXAgY2Fsdmlu"
                        }
                      ]
                    },
                    {
                      "Name": "BIOS",
                      "Scripts": [
                        {
                          "Name": "VT",
                          "Script": "L29wdC95dW5qaS9vc2ludGFsbC9kZWxsL2Jpb3Muc2ggLXQgZW5hYmxl"
                        },
                        {
                          "Name": "C-States",
                          "Script": "L29wdC95dW5qaS9vc2ludGFsbC9kZWxsL2Jpb3Muc2ggLWMgZGlzYWJsZQ=="
                        }
                      ]
                    }
                  ],
                  "ModelName": "R420",
                  "Product": "PowerEdge"
                },
                "Message": "成功获取hardware信息",
                "Status": "success"
              }


/device/getSystemBySn:
  get:
    description: 根据SN获取系统信息
    queryParameters:
      sn:
        description: SN号
        type: string
        required: true
      type:
        description: 输出类型,json或raw(直接输出原始格式)，默认为raw
        type: string
        required: true
    responses:
      200:
        body:
          text/html:
            example: |
              ...


/device/getNetworkBySn:
  get:
    description: 根据SN获取网络信息信息
    queryParameters:
      sn:
        description: SN号
        type: string
        required: true
      type:
        description: 输出类型,json或raw(直接输出原始格式)，默认为raw
        type: string
        required: true
    responses:
      200:
        body:
          text/html:
            example: |
              IPADDR="192.168.1.1"
              NETMASK="255.255.255.192"
              GATEWAY="192.168.1.100"



/device/isInInstallList:
  post:
    description: 是否在装机队列里
    queryParameters:
      Sn:
        description: SN号
        type: string
        required: true
    responses:
      200:
        body:
          application/json:
            example: |
              {
                "Status": "success",
                "Message": "",
                "Content": {
                	"Result":"true"
                }
              }

/report/deviceProductInfo:
  post:
    description: 上传服务器厂商、产品名称、设备型号信息
    queryParameters:
      Sn:
        description: SN号
        type: string
        required: true
      Company:
        description: 厂商
        type: string
        required: true
      ModelName:
        description: 服务器型号
        type: string
        required: false
      Nic:
        description: 网卡信息
        type: Nic[]
        required: false
      Cpu:
        description: CPU信息
        type: Cpu
        required: false
      Memory:
        description: 内存信息
        type: Memory[]
        required: false
      MemorySum:
        description: 内存总容量(MB)
        type: Number
        required: false
      Disk:
        description: 硬盘信息
        type: Disk[]
        required: false
      DiskSum:
        description: 硬盘总容量(GB)
        type: Number
        required: false
      Motherboard:
        description: 主板信息
        type: Motherboard
        required: false
      Raid:
        description: Raid
        type: string
        required: false
      Oob:
        description: Oob
        type: string
        required: false

    responses:
      200:
        body:
          application/json:
            example: |
              {
                "Status": "success",
                "Message": "",
              }

/device/getPrepareInstallInfo:
  post:
    description: 装机之前，获取是否匹配到硬件配置库，是否略过硬件配置等信息
    queryParameters:
      Sn:
        description: SN号
        type: string
        required: true
      Company:
        description: 厂商
        type: string
        required: true
      ModelName:
        description: 产品型号
        type: string
        required: false

    responses:
      200:
        body:
          application/json:
            example: |
              {
                "Status": "success",
                "Message": "",
                "Content": {
                  "IsVerify":"true" //true:能匹配到硬件配置库,false:未匹配到硬件配置库
                  "IsSkipHardwareConfig":"false",//true:略过硬件配置安装步骤,false:不略过
                }
              }


/report/deviceInstallInfo:
  post:
    description: 上传设备安装进度及日志信息
    queryParameters:
      Sn:
        description: SN号
        type: string
        required: true
      Title:
        description: 安装进度主题
        type: string
        required: true
      InstallProgress:
        description: 安装进度(常规进度为0 ~ 1之间的小数，如0.1；安装失败传-1，安装成功传1；后端会保存小数点后4位)
        type: string
        required: true
      InstallLog:
        description: 安装日志
        type: string
        required: false
    responses:
      200:
        body:
          application/json:
            example: |
              {
                "Status": "success",
                "Message": "",
                "Content": {
                  "Result":"true"
                }
              }

/report/deviceMacInfo:
  post:
    description: 上传设备Mac地址信息，后端会根据Mac地址生成PXE文件，安装进度为100%时则删掉此文件。
    queryParameters:
      Sn:
        description: SN号
        type: string
        required: true
      Mac:
        description: mac地址
        type: string
        required: true
    responses:
      200:
        body:
          application/json:
            example: |
              {
                "Status": "success",
                "Message": "",
                "Content": {
                  "Result":"true"
                }
              }
